<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    /* 
     1、箭头函数只有一个参数可以省略小括号
     2、箭头函数返回值只有一条语句可以省略return和{}
     3、箭头函数没有内置对象arguments
     4、箭头函数不能是构造函数
     5、箭头函数的this不能发生改变，call和apply能调用箭头函数
     6、箭头函数没有原型对象
     7、箭头函数的this指向父作用域 （定义它的地方）
    */
    var fn = x => {
        console.log(x);
    }
    fn(10)
</script>
<script>
    // var fn_1 = (y) =>{ return y }
    var fn_1 = y => y
    console.log(fn_1(20));
</script>
<script>
    var fn_2 = function () {
        console.log(arguments);
    }
    fn_2()
    var fn_2 = () => {
        console.log(arguments); // arguments is not defined
    }
    fn_2()
</script>
<script>
    // var Person = function () {

    // }
    // console.log(Person.prototype);
    // var p1 = new Person()
    // console.log(p1);

    var Person = () => {

    }
    console.log(Person.prototype);

    // var p1 = new Person()
    // console.log(p1); // Person is not a constructor
</script>
<script>
    var obj = {
        age: 18
    }
    // var fn_3 = function () {
    //     console.log(this);
    // }
    // fn_3()
    // fn_3.call(obj)
    // fn_3.apply(obj)

    var fn_3 = () => {
        console.log(this);
    }
    fn_3()
    fn_3.call()
    fn_3.call(obj)
    // fn_3.apply(obj)
</script>
<script>
    var obj = {
        name: "ls",
        say: () => {
            console.log(this);
        }
    }
    obj.say()
</script>
<script>
    // var obj = {
    //     birth: 1990,
    //     getAge: () => {
    //         console.log(this.birth);
    //         console.log(new Date().getFullYear() - this.birth);
    //     },
    // }
    // console.log(obj.age);
    // obj.getAge(); //  34   undefined 报错 NaN

</script>
<script>
    var birth = 2000
    var obj = {
        birth: 1990,
        getAge: () => {
            var fn = function () {
                return new Date().getFullYear() - this.birth;
            };
            return fn();
        }
    };
    console.log(obj.getAge());// NaN   报错 34 NaN  24

</script>
<script>
    console.log(Number.isNaN == isNaN);
</script>

</html>